<?php
require ('../database/categories.php');
?>
<?php $cate=new categories();
//$data=$cate->showAll();
$record=$cate->getRecord();
if(!isset($_GET['trang']))$_GET['trang']=1;
$vitri=($_GET['trang']-1)*10;// chon 10 ban ghi
$data=$cate->page($vitri);
?>
<style>
    #category{
        height:  699px;
        border-bottom: 1px solid #0099FF;
    }
    #page{
        height: 60px;
    }
</style>
   <script type="text/javascript">
        $(document).ready(function(){
            $("a.del").click(function(){
               if(confirm("Bạn có muốn xóa không ?")){
                  $id=$(this).attr("name"); 
                  $(this).parent().parent().fadeOut("slow");                 
                  $.ajax({
                      "url": "modules/category/deleteajax.php",                     "type":"post",
                      "data":"uid="+$id,
                      "async":"false",
                      success: function (data) {                     
                    }
                  });
               } 
               return false;
              
            });
        });
        </script>
        <div id="category">
        <table border="1px">
            <tr>
                 <th>Id</th>
                 <th>Ten </th>
                 <th>Thong tin </th>
                 <th>Trang thai</th>
            </tr>
        <?php 
        if($data){
        foreach ($data as $value) {   
         ?>
            <tr>
                <td><?php echo $value['cate_Id']?></td>
                <td><?php echo $value['cate_name']?></td>
                <td><?php echo $value['cate_infor']?></td>
                <td><?php echo $value['cate_status']?></td>
                <td> 
                    <a href="#"><img src="images/detail.png" width="30" height="30" title="Chi tiet"></a><a href="javascript:void(0)" class="del" name="<?php echo $value['cate_Id'];?>">
                            <img src="images/delete.png" width="30" height="30"title="Xoa"></a>
                        <a href='<?php echo baseurl."admin/index.php?page=category&act=edit&id=".$value['cate_Id'];?>'><img src="images/update.png"width="30" height="30" title="Cap nhat"></a>
                </td>
            </tr>
        <?php } ?>

        </table>
        <?php }else{
             echo 'Du lieu trong ! ';
        }?>

        </div>
        
        <div id="page">
         <?php $tongsotrang= ceil($record/10);
        for($i=1;$i<=$tongsotrang;$i++)
        echo "<a href='index.php?page=category&act=list&trang=$i'>$i</a>";
            ?>
        </div>